package control;

import java.io.IOException;
import java.text.SimpleDateFormat;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import model.Turma;
import dao.DAOTurma;

public class ListarInfoEdicaoTurmaTag extends SimpleTagSupport{

	private int numero;
	
	public void doTag() throws JspException, IOException 
		{
			DAOTurma daotur = new DAOTurma();
			Turma t = daotur.find(numero);
			SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
			String dataini = sdf.format(t.getDataInicio().getTime());
			String datafim = sdf.format(t.getDataFim().getTime());
			getJspContext().setAttribute("turma", t);
			getJspContext().setAttribute("dataini", dataini);
			getJspContext().setAttribute("datafim", datafim);
			getJspBody().invoke(null);
		}
	
	public void setNumero (int n){
		this.numero = n;
	}
}
